package com.tencreat.mapper.mall;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.domain.mall.MallGoodsCut;
import com.tencreat.domain.mall.dto.MallAdminGoodsCutDTO;
import com.tencreat.domain.mall.dto.MallGoodsCutDTO;
import com.tencreat.domain.mall.vo.*;
import com.tencreat.domain.mall.dto.CutRecordPCDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;

/**
 * 砍价商品Mapper接口
 *
 * @author wangkai
 * @date 2021-11-04
 */
@Repository
public interface MallGoodsCutMapper extends BaseMapper<MallGoodsCut> {

    Page<ResMallGoodsCutsVO> cutGoodsPage(@Param("page") IPage<ResMallGoodsCutsVO> page, @Param("dto") MallGoodsCutDTO mallGoodsCutDTO,@Param("now") LocalDateTime now);

    ResGoodsCutDetailVO selectMallGoodsCutById(Long id);

    Page<ResMyCutInfosVO> myCutList(@Param("page") Page<ResMallGoodsCutsVO> page, @Param("uuid") Long uuid,@Param("cutStatus") Integer cutStatus);

    Page<MallGoodsCutVO> PCPage(IPage<?> iPage , @Param("param") MallAdminGoodsCutDTO dto);

    Map<String, Object> getDetail(Long cutId);

    Page<Map<String, Object>> cutRecord(@Param("page") Page<Map<String, Object>> page, @Param("vo") CutRecordPCDTO vo);

    Page<Map<String, Object>> cutDetails(@Param("page") Page<Map<String, Object>> page, @Param("cutSn") String cutSn);

    CutOrderInfoVO getCutOrderInfo(String orderSn);

    /**
     * 增加销量
     * @param id 砍价ID
     */
    @Update("update mall_goods_cut set sales_count = sales_count + 1 where id = #{id}")
    void addSales(@Param("id") Long id);

    BigDecimal cutStatistics(@Param("type") Integer type , @Param("day")LocalDateTime day);
}
